package org.cyk.dataes

import org.cyk.dataes.service.AlbumInfoESRepo
import org.elasticsearch.index.query.QueryBuilder
import org.elasticsearch.index.query.QueryBuilders
import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.data.domain.PageRequest
import org.springframework.data.domain.Sort
import javax.annotation.Resource

@SpringBootTest(classes = [DataEsApplication::class])
class RepoTests2 {

    @Resource
    private lateinit var albumInfoESRepo: AlbumInfoESRepo

    @Test
    fun testFindPageAndSort() {
        //从 0 下标开始向后获取 3 个，并根据 id 降序排序
        val result = albumInfoESRepo.findAll(
            PageRequest.of(0, 3,
                Sort.by(Sort.Direction.DESC, "id"))
        )
        result.content.forEach(::println)
    }

}